<template>
    <div class="device-menu">
        <div class="title">
            <div class="title-font">{{ $t('components.whiteList.632umksp32k0') }}</div>
            <div class="delete"><icon-more @click="toWhiteList"/></div>
        </div>
        <div class="info wrap">
            <div class="info-title">{{ $t('components.whiteList.632umksp32k1') }}</div>
            <ul class="device-signal-scroll device-signal-border">
                <li class="signal" v-for="(item, index) in (form.list as any)" :key="index">
                    <div class="model">
                        <div class="img-bg img-bg1"></div>
                        <div>{{ useIdModelFormat(item.uavId).name }}</div>
                    </div>
                    <div class="name">
                        <div class="img-bg  img-bg2"></div>
                        <div>{{ item.customerName }}</div>
                    </div>
                </li>
            </ul>
            <div class="info-title">{{ $t('components.whiteList.632umksp32k2') }}</div>
            <ul class="device-signal-scroll">
                <li class="signal" v-for="(item, index) in (form.list as any)" :key="index">
                    <div class="model">
                        <div class="img-bg img-bg1"></div>
                        <div>{{ useIdModelFormat(item.uavId).name }}</div>
                    </div>
                    <div class="name">
                        <div class="img-bg  img-bg2"></div>
                        <div>{{ item.customerName }}</div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>
<script lang='ts' setup>
import { apiWhiteListList } from '@/api/visual'
import { useIdModelFormat } from "@/hooks/comparison";
const local = useLocal()
const router = useRouter()
const form = reactive({
    data: {
        page: 1,
        pageSize: 10,
        sort: '',
        uavId: '',
        uid: local.usermsg.id == 3 ? 0 : local.usermsg.id
    },
    loading: false,
    list: [],
    count: 0
})
// 白名单列表
const getData = async () => {
    form.loading = true
    const { code, data } = await apiWhiteListList({
        ...form.data
    })
    form.loading = false
    if (code != 200) return;
    form.list = data.list
    form.count = data.total
}
let timer: any
onBeforeMount(async () => {
    await getData()
    timer = setInterval(() => {
        getData()
    }, 3600000)
})
onBeforeUnmount(() => {
    clearInterval(timer)
    timer = null
})
const toWhiteList = () => {
    router.replace('/whiteList')
}
</script>
<style scoped lang="less">
.device-menu {
    height: 365px;
    width: 300px;
    // margin: 20px;
    color: #fff;

    .title {
        width: 100%;
        height: 59px;
        background-image: url('@/assets/images/index-menue-title.png');
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        background-size: 100% 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-top-left-radius: 5px;
        border-top-right-radius: 5px;

        .title-font {
            margin-left: 10px;
            font-family: YouSheBiaoTiHei;
            opacity: 1;
            /** 文本1 */
            font-size: 22px;
            font-weight: 500;
            letter-spacing: 0.48px;
            line-height: 24px;
            vertical-align: middle;
            background-image: -webkit-linear-gradient(bottom, rgb(153 218 252), #ffffff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }



        .delete {
            width: 35px;
            cursor: pointer;
            font-weight: 600;
            font-size: 22px;
            color: rgba(75, 127, 239, 1);
        }
    }

    >.info {
        border: 1px solid rgba(46, 116, 255, 0.8);
        background: rgba(15, 19, 41, 0.85);
        height: 200px;
        border-bottom-left-radius: 8px;
        border-bottom-right-radius: 8px;
        >.info-title {
            padding: 10px 10px 0 10px;
            font-weight: 500;
        }

        >.status {
            display: flex;
            align-items: center;
            justify-content: right;
            width: 100%;

            >.device-status {
                width: 50%;
                height: 50px;
                margin-right: 20px;
                display: flex;
                align-items: center;
                justify-content: space-around;

                >div {
                    display: flex;
                    align-items: center;
                }

                >.online {
                    >.color {
                        background: rgba(36, 189, 255, 1);
                        transform: rotate(-45deg);
                    }
                }

                >.offline {
                    >.color {
                        background: rgba(181, 181, 181, 1);
                        transform: rotate(-45deg);
                    }
                }

                >.threat {
                    >.color {
                        background: rgba(255, 20, 20, 1);
                        transform: rotate(-45deg);
                    }
                }

                .color {
                    width: 5px;
                    height: 5px;
                    transform: rotate(90deg);
                    margin-right: 6px;
                }
            }
        }
        >.device-signal-border {
            border-bottom: 1px solid rgba(46, 116, 255, 0.8);
        }
        >.device-signal-scroll {
            display: flex;
            align-items: center;
            // justify-content: space-around;
            flex-wrap: wrap;
            flex: 1;
            overflow: auto;

            >.signal {
                text-align: center;
                width: 49%;
                margin: 10px 0;
                list-style-type: none;
                padding: 0 0 0 10px;
                position: relative;

                >div {
                    font-size: 13px;
                    font-weight: 500;
                    letter-spacing: 0px;
                    line-height: 17.38px;
                    color: rgba(0, 179, 255, 1);
                    text-align: left;
                    vertical-align: top;
                    display: flex;

                    .img-bg {
                        width: 18px;
                        height: 18px;
                        background-size: cover;
                        background-repeat: no-repeat;
                        background-position: center;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        margin-right: 5px;
                    }

                    .img-bg1 {
                        background-image: url('@/assets/images/white-wanzhou1.png');
                    }

                    .img-bg2 {
                        background-image: url('@/assets/images/white-wanzhou2.png');
                    }
                }
                .model {
                    margin-bottom: 8px;
                }

            }
        }
    }
}
</style>